//
//  MyPictureViewController.m
//  QT
//
//  Created by 甘世清 on 2025/1/6.
//

#import "MyPictureViewController.h"
#import "MyPictureListViewController.h"
#import "MyParticipateViewController.h"
#import "WMDragView.h"
#import "AddPictureViewController.h"
@interface MyPictureViewController ()
@property (nonatomic , strong)MyPictureListViewController * myListVC;
@property (nonatomic , strong)MyParticipateViewController * addListVC;
@property (nonatomic , strong)WMDragView * addView;
@end

@implementation MyPictureViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self SQ_UIViewForSelfView];
    SQCustomButton * rightBtn2 = [[SQCustomButton alloc]initType:SQCustomButtonLeftImageType imageSize:CGSizeMake(14, 14) midmargin:0];
    rightBtn2.image = SQGetImage(@"fanhui");
    [self.view addSubview:rightBtn2];
    [rightBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.tabBar);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(50);
        make.left.equalTo(self.view);
    }];
    WS(weakSelf);
    [rightBtn2 setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];

    [self.view addSubview:self.addView];
    [self.addView setClickDragViewBlock:^(WMDragView *dragView) {
        AddPictureViewController * vc = [[AddPictureViewController alloc]init];
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }];
}

- (void)SQ_UIViewForSelfView{
    
    UIImageView * bgImageView = [[UIImageView alloc]init];
    bgImageView.image = SQGetImage(@"二级背景");
    [self.view addSubview:bgImageView];
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    self.tabContentView.backgroundColor = UIColor.clearColor;
    self.tabBar.backgroundColor = UIColor.clearColor;
    self.tabBar.leadingSpace = 10;
    self.tabBar.trailingSpace = 10;
    self.tabBar.indicatorColor  = SQColor333333;
    [self.tabBar setIndicatorWidth:40 marginTop:42 marginBottom:6 tapSwitchAnimated:YES];
    [self setTabBarFrame:CGRectMake(80, TopHeight-50, SCREEN_WIDETH-160,50)
        contentViewFrame:CGRectMake(0, TopHeight, SCREEN_WIDETH, SCREEN_HEIGHT-TopHeight)];
    self.tabBar.itemTitleFont = FONT_MEDIUM(16);
    self.tabBar.itemTitleColor = SQColor(@"#999999");
    self.tabBar.itemTitleSelectedColor = SQColor333333;
    [self.tabContentView setContentScrollEnabled:YES tapSwitchAnimated:YES];
    self.tabContentView.loadViewOfChildContollerWhileAppear = YES;
    
    self.viewControllers = [[NSMutableArray alloc]initWithObjects:self.myListVC,self.addListVC, nil];
    [self.view sendSubviewToBack:bgImageView];
}
- (MyPictureListViewController *)myListVC{
    if (!_myListVC) {
        _myListVC = [[MyPictureListViewController alloc]init];
 
        _myListVC.yp_tabItemTitle = SQNSLocalString(@"我发布的");
    }
    return _myListVC;
}
- (MyParticipateViewController *)addListVC{
    if (!_addListVC) {
        _addListVC = [[MyParticipateViewController alloc]init];
        _addListVC.yp_tabItemTitle = SQNSLocalString(@"我参与的");
    }
    return _addListVC;
}

- (WMDragView *)addView{
    if (!_addView) {
        _addView = [[WMDragView alloc]initWithFrame:CGRectMake(SCREEN_WIDETH-60, SCREEN_HEIGHT-FootHeight-130, 60, 60)];
        _addView.freeRect = CGRectMake(10, TopHeight, SCREEN_WIDETH-20,SCREEN_HEIGHT-TopHeight-FootHeight-50);
        _addView.imageView.image = SQGetImage(@"tianjia");
        _addView.layer.cornerRadius = 30;
        _addView.layer.masksToBounds = YES;
        _addView.layer.borderWidth = 0.4;
        _addView.layer.borderColor = SQHexColor(@"#000000", 0.4).CGColor;
        _addView.backgroundColor = UIColor.whiteColor;
    }
    return _addView;
}

@end
